<?php



/**
 * Skeleton subclass for representing a row from the 'task_goals' table.
 *
 *
 *
 * You should add additional methods to this class to meet the
 * application requirements.  This class will only be generated as
 * long as it does not already exist in the output directory.
 *
 * @package    propel.generator.empeval
 */
class EmpevalTaskGoals extends EmpevalBaseTaskGoals
{
	
	const STATUS_ACTIVE = 1;
	const STATUS_CANCELED = 0;
	const STATUS_DELETED = -1;
	
	public function calculateResult() {
		if ($this->getWeight() == null || $this->getRealization80() == null || $this->getRealization100() == null)
			return null;
		return ($this->getResultAchieved() === null) ? 0 : (int)$this->getResultAchieved();
// 		switch ((int)$this->getResultAchieved()) {
// 			case 0:
// 				return 100;
// 			case 1:
// 				return 80;
// 			case 2:
// 				return 0;
// 			default:
// 				return null;
// 		}
	}
	
	public function calculateWeightResult() {
		if ($this->getResult() == null)
			return null;
		return $this->getResult() * ($this->getWeight() / 100);
	}
	
	public function setResultAchieved($v) {
		parent::setResultAchieved($v);
		$this->setResult($this->calculateResult());
		$this->setWeightResult($this->calculateWeightResult());
	}
	
}
